<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .outter {
            position: relative;

            width: 400px;
            height: 400px;
            background-color: cadetblue;
        }

        .inner {
            position: absolute;

            width: 200px;
            height: 200px;

            /* 核心代码 */
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);

            background-color: coral;
        }
    </style>
</head>
<body>
    <div class="outter">
        <div class="inner">内部盒子</div>
    </div>
</body>
</html>